<?
load_model('Common');
class WriteMood extends Common {
	protected $_name ="mood";
	protected $_primary = 'mood_id';
	
	public function get_mood_list(){
		$arr = $this->fetchAll(null,"mood_date desc")->toArray();
		return $arr;
	}

	public function get_mood_info($id){
		$db = $this->getAdapter();
		$where = $db->quoteInto('mood_id = ?', $id);
		return $this->fetchRow($where)->toArray();
	}
	
	public function get_lastest_mood(){
		$db = $this->getAdapter();
		$sql = "select * from zf_mood order by mood_date desc limit 1";
		return $db->fetchRow($sql);
	}
	function add_wm($data){
		$dataInsert = array(
		    'mood_content' => $data['mood_content'],
		    'mood_date' => $data['mood_date'],
		);
		return $this->insert($dataInsert);
	}
	
	function update_wm($id, $data){
		$db = $this->getAdapter();
		$where = $db->quoteInto('mood_id = ?', $id);
		return $this->update($data, $where);
	}
	
	function del_wm($id){
		$db = $this->getAdapter();
		$where = $db->quoteInto('mood_id = ?', $id);
		return $this->delete($where);
	}
	
}

?>